<template>
	<view class="container">
    <view class="tips">只允许不超过24个字母、数字或12个汉字</view>
    <view class="list">
      <view class="multi-item">
        <view class="multi-item-child">
           <view class="title">昵称</view>
           <view class="content">
             <input class="uni-input text"  placeholder="请输入昵称"  v-model="nickname" />
           </view>
        </view>
      </view>
    </view>
    <view class="operate-box" @tap="onSubmit">保存</view>
	</view>
</template>

<script>
  import {updateUserInfo} from '@/api/info_setting.js';
  
	export default {
      data() {
        return {
          nickname: '',
          date: '',
          uid: ''
        }
      },
      onLoad(options){
        console.log('options', options)
        if(options.uid){
          this.uid = options.uid
        }
        if(options.nickname){
          this.nickname = options.nickname
        }
      },
      methods: {
              onSubmit(){
                let {nickname, uid} = this
                if(!nickname){
                  uni.showToast({
                    icon: 'none',
                    title: '请填写昵称'
                  })
                  return;
                }
                let params = {
                  id: uid,
                  nickname,
                }
               updateUserInfo(params).then(res => {
                 console.log('res', res)
                 if(res.status == 200){
                   uni.showToast({
                     icon: 'none',
                     title: '保存成功',
                     success() {
                     	uni.navigateBack()
                     }
                   })
                 }else{
                    uni.showToast({ title:res.msg, icon:'none' })
                 }
               }).catch((err)=>{
                   uni.showToast({ title:err, icon:'none' })
               })
              }
      }
	}
</script>

<style lang="scss" scoped>
	page {
    min-height: 100vh;
		background-color: rgb(248,249,252);
	}

	.container {
		padding: 32rpx;
	}
  .tips{
    margin: 124rpx auto 78rpx;
    font-weight: 500;
    font-size: 26rpx;
    color: #8D8E90;
    text-align: center;
  }
  .list{
    
  }
  .item{
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #FFF;
    font-size: 28rpx;
    color: rgba(0,0,0,0.9);
    padding: 32rpx 28rpx;
    border-radius: 10rpx;
    margin-bottom: 24rpx;
  }
  .multi-item{
    width: 686rpx;
    padding: 0rpx 28rpx;
    margin-bottom: 24rpx;
    box-sizing: border-box;
    background: #FFFFFF;
    border-radius: 16rpx 16rpx 16rpx 16rpx;
    .multi-item-child{
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 24rpx 0;
      .title{
         width: 116rpx;
         font-size: 28rpx;
      }
      .content{
        display: flex;
        align-items: center;
        // text-align: right;
        flex: 1;
        padding-left: 20rpx;
        .text{
          margin-right: 10rpx;
          font-size: 28rpx;
          color: rgba(0,0,0,0.4);
          // text-align: right;
          flex: 1;
        }
        .get-code{
          font-size: 28rpx;
          color: #008DFF;
        }
        .picker-inner{
          display: flex;
          align-items: center;
        }
      }
    }
  }
  .operate-box{
    width: 686rpx;
    height: 96rpx;
    line-height: 96rpx;
    margin: 200rpx auto 30rpx;
    box-sizing: border-box;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    font-weight: 600;
    font-size: 32rpx;
    color: #FFFFFF;
    background: #008DFF;
    text-align: center;
    border-radius: 12rpx;
  }
</style>
